<?php

namespace App\Models\Products;

use App\Services\Utils\ImageHelper;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
 * Class ReviewImage
 * @package App\Models\Products
 *
 * @mixin Builder
 */

class ReviewImage extends Model
{
    protected $table = 'review_image';
    protected $guarded = [];

    protected $primaryKey = 'review_image_id';

    /**
     * @return null|string
     */
    public function getImageAttribute()
    {
        $image = $this->attributes['image'] ?? null;

        if (!$image) return null;

        return ImageHelper::generateImagePath($image) ;
    }
}
